/*
 * @Author       : 刘洋 liuy5335@163.com
 * @Date         : 2024-05-15 14:53:57
 * @LastEditors  : 刘洋 liuy5335@163.com
 * @LastEditTime : 2025-02-12 14:42:12
 * @FilePath     : \zhly-vform\src\components\form-designer\widget-panel\templatesConfig.js
 * @Description  : 表单模板数据操作配置方法
 * 
 * Copyright (c) 2024 by zhlx - liuy5335@163.com, All Rights Reserved. 
 */
import { getFormtemplateList } from '@/api/formtemplate'

// 表单模板数据
export let formTemplates = [
  {
    title: '单列表单',
    imgUrl: 'https://ks3-cn-beijing.ksyuncs.com/vform-static/form-samples/t1.png',
    jsonUrl: 'https://ks3-cn-beijing.ksyuncs.com/vform-static/form-samples/json1.txt',
    description: '表单模板详细说明...'
  },

  {
    title: '多列表单',
    imgUrl: 'https://ks3-cn-beijing.ksyuncs.com/vform-static/form-samples/t2.png',
    jsonUrl: 'https://ks3-cn-beijing.ksyuncs.com/vform-static/form-samples/json2.txt',
    description: '表单模板详细说明...'
  },

  {
    title: '分组表单',
    imgUrl: 'https://ks3-cn-beijing.ksyuncs.com/vform-static/form-samples/t3.png',
    jsonUrl: 'https://ks3-cn-beijing.ksyuncs.com/vform-static/form-samples/json3.txt',
    description: '表单模板详细说明...'
  },

  {
    title: '标签页表单',
    imgUrl: 'https://ks3-cn-beijing.ksyuncs.com/vform-static/form-samples/t4.png',
    jsonUrl: 'https://ks3-cn-beijing.ksyuncs.com/vform-static/form-samples/json4.txt',
    description: '表单模板详细说明...'
  },

  {
    title: '主从表单',
    imgUrl: 'https://ks3-cn-beijing.ksyuncs.com/vform-static/form-samples/t5.png',
    jsonUrl: 'https://ks3-cn-beijing.ksyuncs.com/vform-static/form-samples/json5.txt',
    description: '表单模板详细说明...'
  },

  {
    title: '响应式表单',
    imgUrl: 'https://ks3-cn-beijing.ksyuncs.com/vform-static/form-samples/t6.png',
    jsonUrl: 'https://ks3-cn-beijing.ksyuncs.com/vform-static/form-samples/json6.txt',
    description: '表单模板详细说明...'
  },

  {
    title: '问卷调查表',
    imgUrl: 'https://ks3-cn-beijing.ksyuncs.com/vform-static/form-samples/t7.png',
    jsonUrl: 'https://ks3-cn-beijing.ksyuncs.com/vform-static/form-samples/json7.txt',
    description: '表单模板详细说明...'
  },

  {
    title: '固定表格表单',
    imgUrl: 'https://ks3-cn-beijing.ksyuncs.com/vform-static/form-samples/t8.png',
    jsonUrl: 'https://ks3-cn-beijing.ksyuncs.com/vform-static/form-samples/json8.txt',
    description: '表单模板详细说明...'
  },

]

/**
 * 给表单模板字段赋值并返回数据
 */
export async function setFormTemplate () {
  const res = await getFormtemplateList();
  let list  = res.data || [];
  formTemplates = list;
  return list;
}

/**
 * 清空数据模板
 */
export function clearFormTemplates() {
  formTemplates.splice(0, formTemplates.length)
}

/**
 * 添加单个数据模板
 * @param {json} newFormTemplate 
 */
export function addFormTemplate(newFormTemplate) {
  formTemplates.push(newFormTemplate)
}

/**
 * 删除表单模板
 * @param {number} templateIndex 
 */
export function deleteFormTemplate(templateIndex) {
  formTemplates.splice(templateIndex, 1)
}

export function getAllFormTemplates() {
  return formTemplates
}
